﻿using System;

namespace IBNet.UtilsDataStructuresAndExtensions
{
   public static class LongExtensions
   {
      static readonly DateTime NineteenSeventy 
         = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);

      /// <summary>
      /// Converts a seconds-since-1970 long into an equivalent DateTime.
      /// </summary>
      /// <param name="secondsSince1970">A seconds-since-1970 long date.</param>
      /// <returns>An equivalent seconds-since-1970 DateTime.</returns>
      public static DateTime ConvertTo1970DateTime(this long secondsSince1970)
      {
         DateTime secondsSince1970AsDateTime = NineteenSeventy.
            AddSeconds(secondsSince1970).ToLocalTime();
         return secondsSince1970AsDateTime;
      }
   }
}
